package org.csu.webjpetstoreback.controller;

import org.csu.webjpetstoreback.config.CommonResponse;
import org.csu.webjpetstoreback.model.Item;
import org.csu.webjpetstoreback.model.LineItem;
import org.csu.webjpetstoreback.model.Orders;
import org.csu.webjpetstoreback.service.LineItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.sound.sampled.Line;
import java.util.List;

@RestController
@SessionAttributes(names = "httpSession")
@Validated
public class LineItemController {
    @Autowired
    LineItemService lineItemService;

    @GetMapping("/LineItem/{ProductId}")
    public CommonResponse<List<LineItem>> GetLineItemsByProductId(@PathVariable("ProductId")String productId){
        return lineItemService.GetLineItemsByOrderId(productId);
    }
    @PostMapping("/LineItem")
    public CommonResponse<LineItem> PostOrder(@RequestBody LineItem lineItem){
        return lineItemService.PostLineItem(lineItem);
    }
}
